package com.bona.dao.system;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestMapping;

import com.bona.dao.common.BaseDao;
import com.bona.model.system.SysConfigModel;
import com.bona.model.system.SysLogModel;
import com.bona.model.system.SysOperationModel;
import com.bona.model.system.SysSmsModel;

public interface SysCommonDao extends BaseDao {
	
	/**
	 * 获取发送消息
	 * @param model
	 * @return
	 */
	public List<SysSmsModel> querySMs(SysSmsModel model);
	
	/**
	 * 通过操作码获取对象
	 * @param operationCode
	 * @return
	 */
	@Select("select id, operationcode, operationicon, operationname, status, " +
	"functionid,iconid,operationtype from sys_operation where operationcode = #{code}")
	@RequestMapping("SysOperationModel")
	public SysOperationModel queryOptByCode(@Param("code")String code);
	
	/**
	 * 获取配置信息
	 * @param name
	 * @param code
	 * @return
	 */
	@Select("select id, code, name, userid, content, note from sys_config where name=#{name} and code=#{code}")
	@RequestMapping("SysConfigModel")
	public SysConfigModel queryConfig(@Param("name")String name, @Param("code")String code);

	/**
	 * 获取字典信息
	 * @param dictField
	 * @param dictText
	 * @param dictTable
	 * @return
	 */
	@Select("select ${dictField} \"field\", ${dictText} \"text\"	from ${dictTable}")
	public List<Map<String, String>> queryDict(@Param("dictField")String dictField, @Param("dictText")String dictText, @Param("dictTable")String dictTable);
	
	/**
	 * 添加日志
	 * @param model
	 */
	public Integer addLog(SysLogModel model);
	
	/**
	 * 编辑页面检查字段是否重复
	 * @param tableName
	 * @param fieldName
	 * @param fieldValue
	 * @param rowId
	 * @return
	 */
	public Integer queryEditDumplicate(String tableName, String fieldName, String fieldValue, String rowId);
	
	/**
	 * 通过iconId获取关联的菜单功能数量
	 * @param iconId
	 * @return
	 */
	@Select("SELECT COUNT(id) FROM sys_function WHERE iconid=#{iconId} OR desk_iconid=#{iconId}")
	public Integer queryFunctionCountByIconId(@Param("iconId")String iconId);
}
